<template>
  <basic-container>
    <avue-crud v-if="tableOption"
               v-bind="bindVal"
               v-on="onEvent"
               v-model:page="page"
               v-model="startForm">
      <template #menuForm="scope">
        <el-button type="primary" icon="el-icon-check"
                   size="small"
                   plain
                   v-if="getBtnPermission('testDataSource',startForm,null,false)"
                   @click="handleTestDataSource">
          测试连接
        </el-button>
      </template>

    </avue-crud>
  </basic-container>
</template>

<script>
import {testDataSource} from "../../../../api/start/development/datasourceApi";
import {createDynamicMixin} from "../../../../mixins/startCrud.js";

const configOption = {
  name: "start/development/datasource",
  // permissionBtn: {testDataSource: 'start:dataSource:testDataSource'},
  // permissionBtnHandler: {},
}

export default {
  mixins: [createDynamicMixin(configOption)],
  data() {
    return {}
  },
  created() {

  },
  methods: {
    handleTestDataSource() {
      let refForm = this.$refs.crud.$refs.dialogForm.$refs.tableForm.$refs.form;
      refForm.validate((vaild, done) => {
        if (!vaild) return
        testDataSource(this.form).then(res => {
          this.$message.success("数据源获取成功");
        })
      })
    }
  }
}
</script>

<style scoped>

</style>
